package com.boho.system.action;


             
/**
 * 
 *
 * @File name:  AddTSysUserAction.java   添加【系统后台用户:T_USER】
 * @Create on:  2010-05-10 11:27:203
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        

            
import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.estates.po.TPersonnalPO;
import com.boho.system.service.UserService;




public class AddTSysUserAction extends ActionImp {
	
	private String username = null;
	private String loginName = null;
	private String phone = null;
	private String email = null;
	private String remark = null;
	
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("BOHO_COMMON_1001", MessageService.getMessage("BOHO_COMMON_1001"),"【系统后台用户】", ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		
		username = atx.getStringValue("USER_NAME","").trim();
		loginName = atx.getStringValue("LOGIN_NAME","").trim();
		phone = atx.getStringValue("PHONE","").trim();
		email = atx.getStringValue("EMAIL","").trim();
		remark = atx.getStringValue("REMARK","").trim();
		String userid = UserService.addUser(atx, loginName, username, phone, email, remark);
		
		Integer personId = atx.getIntegerValue("PERSON_ID",null);
		TPersonnalPO conditionPO = new TPersonnalPO();
		TPersonnalPO valuePO = new TPersonnalPO();
		conditionPO.setPersonnalNo(personId);
		valuePO.setSysUserID(Integer.valueOf(userid));
		POUtils.update(atx.getConection(), conditionPO, valuePO, false);
		
		atx.setStringValue("USER_ID", userid);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		return 1;
	}
}
